package com.bodacn.packapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.bodacn.packapp.R;
import com.bodacn.packapp.SeachPauseBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SearchPauseAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<SeachPauseBean> list;

    public SearchPauseAdapter(Context context, List<SeachPauseBean> list) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.search_pause_item, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if (list.size() > 0) {
            SeachPauseBean seachPauseBean = list.get(position);
            viewHolder.tvWorkNo.setText(seachPauseBean.getUserNo());
            viewHolder.tvPackno.setText(seachPauseBean.getBasketID());
            viewHolder.tvLZ.setText(seachPauseBean.getSeqNo());
            viewHolder.tvOrder.setText(seachPauseBean.getHyh());
            viewHolder.tvGoods.setText(seachPauseBean.getHh());
            viewHolder.tvPO.setText(seachPauseBean.getPoh());
            viewHolder.tvSize.setText(seachPauseBean.getCm());
            viewHolder.tvStandNum.setText(seachPauseBean.getShl());
            viewHolder.tvComplete.setText(seachPauseBean.getReadyNum());
            if (seachPauseBean.isCheck()){
                viewHolder.cb.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.xuanzhong));
            }else {
                viewHolder.cb.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.weixuan));
            }

        }

        return convertView;
    }



    class ViewHolder {
        @BindView(R.id.tv_packno)
        TextView tvPackno;
        @BindView(R.id.tv_LZ)
        TextView tvLZ;
        @BindView(R.id.tv_order)
        TextView tvOrder;
        @BindView(R.id.tv_goods)
        TextView tvGoods;
        @BindView(R.id.tv_PO)
        TextView tvPO;
        @BindView(R.id.tv_size)
        TextView tvSize;
        @BindView(R.id.tv_stand_num)
        TextView tvStandNum;
        @BindView(R.id.tv_complete)
        TextView tvComplete;
        @BindView(R.id.tv_work_no)
        TextView tvWorkNo;
        @BindView(R.id.cb)
        ImageView cb;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
